package com.bitnpulse.dev2.jjh.engstudybook_free.dialog;

import android.content.Context;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.bitnpulse.dev2.jjh.engstudybook_free.R;
import com.bitnpulse.dev2.jjh.engstudybook_free.listener.IPopUpButtonEventListener;

public class FourButtonDialog extends CustomDialog implements android.view.View.OnClickListener{
	
	private Context mContext_;
	private TextView mTxtContent_;
	private Button mBtn1, mBtn2, mBtn3, mBtn4;
	
	protected boolean isOkResult;
	
	private IPopUpButtonEventListener mPopUpButtonEventListener;
	
	public FourButtonDialog(Context context) {
		super(context);
		mContext_ = context;
		mDialogType = DIALOG_TYPE_TWO_BUTTON_READ_SPEED;
		
		setContentView(R.layout.dialog_four_button);
		
		mTxtContent_ = (TextView)findViewById(R.id.txtContent);
		mBtn1 = (Button)findViewById(R.id.btn1);
		mBtn2 = (Button)findViewById(R.id.btn2);
		mBtn3 = (Button)findViewById(R.id.btn3);
		mBtn4 = (Button)findViewById(R.id.btn4);
		
		
		mBtn1.setOnClickListener(this);
		mBtn2.setOnClickListener(this);
		mBtn3.setOnClickListener(this);
		mBtn4.setOnClickListener(this);
	}
	
	
	public void show(String title, String content, String btnOkText, String btnCancelText){
		setTitle(title);
		mTxtContent_.setText(content);
//		mBtnOk_.setText(btnOkText);
//		mBtnCancel_.setText(btnCancelText);
		show();
	}
	
	public void setButtonListener(IPopUpButtonEventListener listener){
		mPopUpButtonEventListener = listener;
	}
	
	@Override
	public void onClick(View v) {
		int id = v.getId();
		
		switch(id){
			case R.id.btn1 :
				isOkResult = true;
				if(mPopUpButtonEventListener != null){
					mPopUpButtonEventListener.buttonEvent(1);
				}
				break;
			case R.id.btn2 :
				isOkResult = false;
				
				if(mPopUpButtonEventListener != null){
					mPopUpButtonEventListener.buttonEvent(2);
				}
				break;
			case R.id.btn3 :
				isOkResult = false;
				
				if(mPopUpButtonEventListener != null){
					mPopUpButtonEventListener.buttonEvent(3);
				}
				break;
			case R.id.btn4 :
				isOkResult = false;
				
				if(mPopUpButtonEventListener != null){
					mPopUpButtonEventListener.buttonEvent(4);
				}
				break;
		}
		dismiss();
	}

	
	public boolean getIsOkResult(){
		return isOkResult;
	}
}
